package samfeng.erp.product.specification.dal.mysql;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import samfeng.erp.product.specification.controller.admin.vo.SpecificationExportReqVO;
import samfeng.erp.product.specification.controller.admin.vo.SpecificationPageReqVO;
import samfeng.erp.product.specification.dal.dataobject.SpecificationDO;

/**
 * 产品规格 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface SpecificationMapper extends BaseMapperX<SpecificationDO> {

    default PageResult<SpecificationDO> selectPage(SpecificationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SpecificationDO>()
                .betweenIfPresent(SpecificationDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(SpecificationDO::getName, reqVO.getName())
                .eqIfPresent(SpecificationDO::getValue, reqVO.getValue())
                .eqIfPresent(SpecificationDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(SpecificationDO::getProductId, reqVO.getProductId())
                .orderByDesc(SpecificationDO::getId));
    }

    default List<SpecificationDO> selectList(SpecificationExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SpecificationDO>()
                .betweenIfPresent(SpecificationDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(SpecificationDO::getName, reqVO.getName())
                .eqIfPresent(SpecificationDO::getValue, reqVO.getValue())
                .eqIfPresent(SpecificationDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(SpecificationDO::getProductId, reqVO.getProductId())
                .orderByDesc(SpecificationDO::getId));
    }

}
